package controllers.listeners.feature;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;

import objects.Constituent;
import objects.Lexicon;

import views.ViewFeatures;

/* Loads the features under the selected label */
/* actionPerformed when you click the "Go" button */
public class FeatureNavigationByLabelActionListener implements ActionListener {
	
	private ViewFeatures view;
	private ArrayList<Constituent> constituents;
	private ArrayList<Lexicon> lexicons;
	
	public FeatureNavigationByLabelActionListener() {
		view = null;
		constituents = null;
		lexicons = null;
	}
	
	@Override
	public void actionPerformed(ActionEvent e) {
		int index = view.getSelectedLabelIndex();
		if(view.getSelectedFeatureType().equals("Semantic Rep")) {
			view.loadConstituent(constituents.get(index));
		}
		else if(view.getSelectedFeatureType().equals("Lexicon")) {
			view.loadLexicon(lexicons.get(index));
		}
	}
	
	public void setConstituents(ArrayList<Constituent> constituents) {
		this.constituents = constituents;
	}
	
	public void setLexicons(ArrayList<Lexicon> lexicons) {
		this.lexicons = lexicons;
	}
	
	public void setView(ViewFeatures view) {
		this.view = view;
	}
}
